package com.wanho.java157.SystemSetting.service.impl;

import com.wanho.java157.SystemSetting.mapper.MenuMapper;
import com.wanho.java157.SystemSetting.po.Employee;
import com.wanho.java157.SystemSetting.po.Menu;
import com.wanho.java157.SystemSetting.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> selectMenuByEmployeeid(Employee employee) {
        return menuMapper.selectMenuByEmployeeid(employee);
    }

    @Override
    public List<Menu> selectMenuByAmbiguousName(String Name) {
        return menuMapper.selectMenuByAmbiguousName("%" + Name + "%");
    }

    @Override
    public Menu selectMenuByMenuId(String menuId) {
        return menuMapper.selectMenuByMenuId(menuId);
    }

    @Override
    public Menu selectMenuByMenuName(String menuName) {
        return menuMapper.selectMenuByMenuName(menuName);
    }

    @Override
    public List<Menu> selectAllParentMenu() {
        return menuMapper.selectAllParentMenu();
    }

    @Override
    public Boolean insertMenu(Menu menu) {
        if(menu.getParentMenuId()==0){
            Menu Nmenu=new Menu();
            Nmenu.setMenuName(menu.getMenuName());
            Nmenu.setMenuUrl(menu.getMenuUrl());
            Nmenu.setPictures(menu.getPictures());
            return menuMapper.insertMenu(Nmenu);
        }
        return menuMapper.insertMenu(menu);
    }

    @Override
    public Boolean updateMenuDetailById(Menu menu) {
        return menuMapper.updateMenuDetailById(menu);
    }

    @Override
    public Boolean deleteById(String menuId) {
        return menuMapper.deleteById(menuId);
    }


}
